home *** CD-ROM | disk | FTP | other *** search
/ SPACE 1 / SPACE - Library 1 - Volume 1.iso / program / 16 / connect.fth < prev    next >
Text File  |  1985-11-19  |  1KB  |  57 lines

  1. \ Virtual terminal program.
  2. \ Edit  line-modes  to reflect your serial line configuration.
  3. \
  4. \ line-modes    initializes the serial line.
  5. \ connect    go into virtual terminal mode.
  6. \
  7. \ Type  ~.   to get back to Forth.
  8.  
  9. needs  task:  tasking.fth
  10. needs  m-key  modem.fth
  11.  
  12. ascii ~ constant escchar
  13. ascii . constant endchar
  14.  
  15. : m-key-pause  ( -- char )
  16.    begin  pause  m-key? until
  17.    m-key
  18. ;
  19. : key-pause  ( -- char )
  20.    begin  pause  key?   until
  21.    key
  22. ;
  23.  
  24. \ Listen to the keyboard and send the characters to the modem
  25. : >modem  ( -- )
  26.    begin
  27.       key-pause
  28.       dup escchar =
  29.       if  key-pause
  30.           dup endchar =
  31.           if   true
  32.       else dup escchar <>  \ don't double ecsapes
  33.                if escchar m-emit then
  34.                m-emit  false
  35.       then
  36.       else m-emit false
  37.       then
  38.    until
  39. ;
  40.  
  41. \ Listen to the modem and send the characters to the display
  42. : modem>  ( -- )
  43.    begin  m-key-pause emit   again
  44. ;
  45.  
  46. task: m>-task
  47. ' modem> m>-task fork
  48.  
  49. : line-modes  ( -- )
  50.    9600-baud  1-stop-bit  8-bits  no-parity  use-xon/xoff  set-line
  51. ;
  52. : connect  ( -- )
  53.    cursor-on  m>-task wake  >modem  m>-task sleep
  54. ;
  55. ck  bfbase @  b/buf  cmove         ( )
  56.   bfbase @  b/buf  +                    ( end )
  57.   dup bflimit !